package com.project.service.impl;

import com.project.bean.EmployeeBean;
import com.project.mapper.IEmployeeMapper;
import com.project.service.IEmployeeService;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * 员工业务接口实现类
 */
public class EmployeeServiceImpl extends BaseService implements IEmployeeService {
    @Override
    public void add(EmployeeBean em, Integer deptId) {
        SqlSession session = this.getSession();
        IEmployeeMapper mapper = session.getMapper(IEmployeeMapper.class);
        mapper.add(em,deptId);
        session.commit();
        session.close();
    }

    @Override
    public List<EmployeeBean> findAll() {
        SqlSession session = this.getSession();
        IEmployeeMapper mapper = session.getMapper(IEmployeeMapper.class);
        List<EmployeeBean> list = mapper.findAll();
        session.close();
        return list;
    }

    @Override
    public EmployeeBean findById(Integer id) {
        SqlSession session = this.getSession();
        IEmployeeMapper mapper = session.getMapper(IEmployeeMapper.class);
        EmployeeBean em = mapper.findById(id);
        session.close();
        return em;
    }
}
